
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>毕设抽题</title>
	
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <link rel="stylesheet" type="text/css" href="css/base.css">   
    <link rel="stylesheet" type="text/css" href="css/subject.css">
	<style type="text/css">
		.info {
            color:red;
            font-size:16px;
            line-height: 30px;
            margin-left: 2em;
        }
	    .contact{
            margin-top: 10px;
        }
	</style>
  </head>
  
  <body>
      <div class="containner">
      		<div class="regist-title">
      			如有问题，请联系管理员！联系电话110.
      		</div>
      		<div class="contact">
				<div class="clearfix">

					<div class="lf input-lable">
						学号:
					</div>
					<div class="lf input-containner">
						<input type="text" name="sno" id = "sno" size="12" maxlength="12" autocomplete="off"/>
					</div>
				</div>

				<div class="clearfix">

					<div class="lf input-lable">
						姓名:
					</div>
					<div class="lf input-containner">
						<input type="text" name="sname" id = "sname" size="12" maxlength="12" autocomplete="off"/>
					</div>
				</div>
				<div class="submit" id = "submit">
					抽题
				</div>

				<div id = "info" class = "info">


				</div>
      		</div>
	  </div>
      <script type="text/javascript" src="js/jquery-1.8.3.js"></script>
      <script type="text/javascript">
        $("#submit").click(function () {
            var sno = $.trim($("#sno").val());
            var sname = $.trim($("#sname").val());
            if(sno == ""){
               alert("学号不能为空");
               return;
            }
            if(sno.length != 9){
                alert("学号必须是9位");
                return;
            }
            if(sname == ""){
                alert("姓名不能为空");
                return;
            }

            $.ajax({
                type : "GET",
                url : "http://127.0.0.1:8888/subject/extract/" + sno + "/" + sname,
                dataType : "json",
                success : function (subjectJson) {
                    if(null == subjectJson){
                        $("#info").html("对不起，题库已用完！");
                    }else{
                        var  htmlStr = "";
                        if(subjectJson.status == "1"){//已经抽取过了
                            htmlStr += "您已经抽过课题了，"
                        }else{//首次抽中
                            htmlStr += "恭喜您抽中了一个课题，";
                        }
                        htmlStr += "您抽到的课题是：" + subjectJson.subjectName + "<br/>";
                        htmlStr += "指导老师是:" + subjectJson.teacherName +"<br/>";
                        htmlStr += "联系方式是:" + subjectJson.teacherContact + "<br/>";
                        $("#info").html(htmlStr);
                    }
                }

            });
        });

		  
	  </script>

  </body>
</html>
